﻿<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <%
        String path = request.getContextPath();
        String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
    %>
    <link rel="stylesheet" href="<%=path %>/css/common.css">
    <link rel="stylesheet" href="<%=path %>/css/main.css">
    <link rel="stylesheet" href="<%=path %>/css/layui.css">
    <link rel="stylesheet" href="<%=path %>/css/my.css">
    <title>Document</title>
    <script src="<%=path %>/js/jquery-1.12.4.js"></script>

</head>
<body>


<div class="container">

    <div id="search_bar" class="mt10">
        <div class="box">


            <div class="box_border">
                <div class="box_top"><b class="pl15">搜索</b></div>
                <div class="box_center pt10 pb10">

                    <form action="<%=path%>/searchStudent" method="post">
                        <table class="form_table" border="0" cellpadding="0" cellspacing="0">

                            <tr>
                                <td>学号</td>
                                <td><input type="text" name="id" class="input-text lh25" size="20"></td>

                                <td>
                                    <input type="submit" value="查询" class="ext_btn ext_btn_submit">
                                </td>

                            </tr>

                        </table>
                    </form>
                </div>

            </div>
        </div>
    </div>
    <div id="table" class="mt10">
        <div class="box span10 oh">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
                    <th width="3%">#</th>
                    <th width="8%">学号</th>
                    <th width="6%">姓名</th>
                    <th width="4%">性别</th>
                    <th width="14%">身份证</th>
                    <th width="10%">联系电话</th>
                    <th width="10%">学院</th>
                    <th width="15%">班级</th>

                    <th>
                        操作
                    </th>
                </tr>


                <c:forEach var="student" items="${studentPage.data}">
                    <tr class="tr">
                        <td class="td_center"><input type="checkbox"></td>
                        <td class="td_center">${student.id}</td>
                        <td class="td_center">${student.name}</td>
                        <td class="td_center">${student.sex}</td>
                        <td class="td_center">${student.card}</td>
                        <td class="td_center">${student.phone}</td>
                        <td class="td_center">${student.department}</td>
                        <td class="td_center">${student.banji}</td>

                        <td class="td_center">
                            <a title="编辑" class="layui-btn layui-btn-sm layui-btn-normal"
                               href="<%=path %>/modifyStudent/${student.id}">
                                编辑
                            </a>
                            <a class="layui-btn layui-btn-sm layui-btn-warm" title="重置密码"
                               href="<%=path %>/modifyStudentPassword.jsp">
                                修改密码
                            </a>
                            <a title="删除" class="layui-btn layui-btn-sm layui-btn-danger"
                               onclick="deleteStudent('${student.id}')"
                               href="javascript:void(0)">
                                删除
                            </a>
                        </td>
                    </tr>
                </c:forEach>


            </table>

            <c:if test="${studentPage.total==0}">
                <h2 style="text-align: center;margin: 100px;">无数据</h2>
            </c:if>
            <div id="resultRecords">
                共 ${studentPage.total} 条记录,
                当前第 ${studentPage.currentPage} 页,
                共 ${studentPage.totalPage} 页，
                每页显示
                <select onchange="changePageSize(this)">
                    <c:forEach items="5,10,20,50" var="num">
                        <c:if test="${studentPage.pageSize==num}">
                            <option selected>${num}</option>
                        </c:if>
                        <<c:if test="${studentPage.pageSize!=num}">
                        <option>${num}</option>
                    </c:if>
                    </c:forEach>
                </select>
                条
            </div>

            <div class="page mt10">

                <div class="pagination">
                    <ul>
                        <li><a href="<%=path %>/studentList/1/${pageSize}">首页</a></li>
                        <li class=""><a
                                href="<%=path %>/studentList/${studentPage.currentPage==1?1:studentPage.currentPage-1}/${studentPage.pageSize}">上一页</a>
                        </li>
                        <li class="<"><a
                                href="<%=path %>/studentList/${studentPage.currentPage>=studentPage.totalPage?studentPage.currentPage:studentPage.currentPage+1}/${studentPage.pageSize}">下一页</a>
                        </li>
                        <li><a href="<%=path %>/studentList/${studentPage.totalPage}/${studentPage.pageSize}">末页</a>
                        </li>
                    </ul>

                </div>

            </div>
        </div>
    </div>


</div>
<script src="<%=path%>/js/layer.js"></script>
<script>
    function deleteStudent(id) {
        layer.confirm('确定删除？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.post("<%=path%>/deleteStudent", {id: id}, function (resp) {
                layer.msg(resp.message, {icon: 1});
                setTimeout(function () {
                    location.reload();
                }, 3000);
            })
        }, function () {
        });
    }

    function changePageSize(that) {
        location.href = "<%=path%>/studentList/${currentPage}/" + that.value;
    }
</script>
</body>
</html>

  